<?php

// $Id$

function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty) {
	global $_SMARTY_DBC;
	$dbc = $_SMARTY_DBC;

	$tpl_name = addslashes($tpl_name);
	$sql = "select tpl_source from smarty_templates where tpl_name= '$tpl_name'";
	$rez = $dbc->execute($sql);
	if (!$rez->is_eod()) {
		$rez_obj = $rez->fetch_object();
		$tpl_source = stripslashes($rez_obj->TPL_SOURCE);
		return true;
	} else {
		return false;
	}
}

function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smarty) {
	global $_SMARTY_DBC;
	$dbc = $_SMARTY_DBC;

	$tpl_name = addslashes($tpl_name);

	$sql = "select tpl_timestamp from smarty_templates	where tpl_name = '$tpl_name'";
	$rez = $dbc->execute($sql);
	if (!$rez->is_eod()) {
		$rez_obj = $rez->fetch_object();
		$tpl_timestamp = $rez_obj->TPL_TIMESTAMP;
		return true;
	} else {
		return false;
	}
}

function smarty_resource_db_secure($tpl_name, &$smarty) {
	// assume all templates are secure
	return true;
}

function smarty_resource_db_trusted($tpl_name, &$smarty) {
	// not used for templates
}
